$(document).ready(function(){
	// 初始化分页组件
	initPagination();
});


// 初始化分页组件
function initPagination() {
	var num_entries = Number($("#totalItemsSize").val());
	var eachPageSize = Number($("#eachPageSize").val());
	var prePage = $("#page").val();
	var current_page_val = 0;
	if (prePage > 1) {
		current_page_val = Number(prePage) - 1;
	}
	//if (num_entries > 0 && num_entries > eachPageSize) {
		var totalPageVal = parseInt(num_entries / eachPageSize);
		if ((num_entries % eachPageSize) > 0) {
			totalPageVal = totalPageVal + 1;
		}
		if (current_page_val >= totalPageVal) {
			current_page_val = totalPageVal - 1;
		}
		$("#Pagination").pagination(num_entries, {
					num_edge_entries : 1,
					num_display_entries : 3,
					callback : pageselectCallback,
					items_per_page : eachPageSize,
					current_page : current_page_val,
					prev_text : "上一页",
					next_text : "下一页"
				});
	//} else {
	//	loadEachPageAccountItemInfo(1);
	//}
}

// 分页回调函数
function pageselectCallback(page_index, jq) {
	loadEachPageAccountItemInfo(page_index + 1);
	return false;
}

// 异步加载分页数据
function loadEachPageAccountItemInfo(pageNum) {
	$.ajax({
	   type: "POST",
	   url: "bulletin/page",
	   data: {
	   		page:pageNum,
	   		pageFrom : 0
	   },
	   success: function(html){
	     $("#cont_box_list").html(html);
   	   }
	});	 
}

function view(pkid){
	$.ajax({
	   type: "POST",
	   url: "bulletin/view",
	   data: {
	   		pkid:pkid
	   },
	   success: function(html){
	     $("#content").html(html);
   	   }
	});	
}